package org.simple.webserver.server;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.DispatcherHandler;

/**
 * @author HaiLang
 * @date 2021/8/19 6:41 下午
 */
@Configuration(proxyBeanMethods = false)
@ConditionalOnMissingBean(ReactiveWebServerFactory.class)
@ConditionalOnClass({MyWebServer.class, MyReactiveWebServerFactory.class})
public class EmbeddedMyServer {

    @Bean
    @ConditionalOnMissingBean
    MyReactiveWebServerFactory nginxReactiveWebServerFactory(ObjectProvider<DispatcherHandler> dispatcherHandlers) {
        MyReactiveWebServerFactory factory = new MyReactiveWebServerFactory();
        return factory;
    }
}
